package factory;

import com.almasb.fxgl.dsl.FXGL;
import com.almasb.fxgl.entity.*;
import com.almasb.fxgl.entity.SpawnData;
import com.almasb.fxgl.entity.Spawns;
import comgame.components.MovementComponent;
import comgame.entities.EntityType;
import javafx.scene.image.Image;
import javafx.scene.image.ImageView;

public class Fishfactory implements EntityFactory {
    @Spawns("RedFish")
    public Entity newFish(SpawnData data) {
        Image image = new Image("/assets/textures/fish_red.png");
        ImageView imageView = new ImageView(image);
        return FXGL.entityBuilder()
                .type(EntityType.Fish)
                .at(data.getX(), data.getY())
                .viewWithBBox(imageView)
                .with(new MovementComponent())
                .zIndex(2) // 一定要比背景大
                .buildAndAttach();
    }

    @Spawns("GreenFish")
    public Entity newGreenFish(SpawnData data) {
        Image image = new Image("/assets/textures/fish_green.png");
        ImageView imageView = new ImageView(image);
        return FXGL.entityBuilder()
                .type(EntityType.Fish)
                .at(data.getX(), data.getY())
                .viewWithBBox(imageView)
                .with(new MovementComponent())
                .zIndex(2)
                .buildAndAttach();
    }

    @Spawns("GrayFish")
    public Entity newGrayFish(SpawnData data) {
        Image image = new Image("/assets/textures/fish_grey.png");
        ImageView imageView = new ImageView(image);
        imageView.setFitWidth(image.getWidth() * 1.1); // 稍大
        imageView.setFitHeight(image.getHeight() * 1.1);
        return FXGL.entityBuilder()
                .type(EntityType.Fish)
                .at(data.getX(), data.getY())
                .viewWithBBox(imageView)
                .with(new MovementComponent())
                .zIndex(2)
                .buildAndAttach();
    }

    @Spawns("BrownFish")
    public Entity newBrownFish(SpawnData data) {
        Image image = new Image("/assets/textures/fish_brown.png");
        ImageView imageView = new ImageView(image);
        imageView.setFitWidth(image.getWidth() * 1.1); // 稍大
        imageView.setFitHeight(image.getHeight() * 1.1);
        return FXGL.entityBuilder()
                .type(EntityType.Fish)
                .at(data.getX(), data.getY())
                .viewWithBBox(imageView)
                .with(new MovementComponent())
                .zIndex(2)
                .buildAndAttach();
    }

    @Spawns("OrangeFish")
    public Entity newOrangeFish(SpawnData data) {
        Image image = new Image("/assets/textures/Fishing_orange.png");
        ImageView imageView = new ImageView(image);
        imageView.setFitWidth(image.getWidth() * 1.1);
        imageView.setFitHeight(image.getHeight() * 1.1);
        return FXGL.entityBuilder()
                .type(EntityType.Fish)
                .at(data.getX(), data.getY())
                .viewWithBBox(imageView)
                .with(new comgame.components.MovementComponent())
                .zIndex(2)
                .buildAndAttach();
    }

    @Spawns("PinkFish")
    public Entity newPinkFish(SpawnData data) {
        Image image = new Image("/assets/textures/Fishing_pink.png");
        ImageView imageView = new ImageView(image);
        imageView.setFitWidth(image.getWidth() * 1.1);
        imageView.setFitHeight(image.getHeight() * 1.1);
        return FXGL.entityBuilder()
                .type(EntityType.Fish)
                .at(data.getX(), data.getY())
                .viewWithBBox(imageView)
                .with(new comgame.components.MovementComponent())
                .zIndex(2)
                .buildAndAttach();
    }

    @Spawns("RedKingFish")
    public Entity newRedKingFish(SpawnData data) {
        Image image = new Image("/assets/textures/fish_red_King.png");
        ImageView imageView = new ImageView(image);
        imageView.setFitWidth(image.getWidth() * 2.5);
        imageView.setFitHeight(image.getHeight() * 2.5);
        return FXGL.entityBuilder()
                .type(EntityType.Fish)
                .at(data.getX(), data.getY())
                .viewWithBBox(imageView)
                .with(new comgame.components.MovementComponent())
                .zIndex(2)
                .buildAndAttach();
    }

    @Spawns("LiangziFish")
    public Entity newLiangziFish(SpawnData data) {
        Image image = new Image("/assets/textures/fish_Jackfish.png");
        ImageView imageView = new ImageView(image);
        imageView.setFitWidth(image.getWidth() * 0.8);
        imageView.setFitHeight(image.getHeight() * 0.8);
        return FXGL.entityBuilder()
                .type(EntityType.Fish)
                .at(data.getX(), data.getY())
                .viewWithBBox(imageView)
                .with(new comgame.components.MovementComponent())
                .zIndex(2)
                .buildAndAttach();
    }

    @Spawns("ArcticShrimp")
    public Entity newArcticShrimp(SpawnData data) {
        Image image = new Image("/assets/textures/fish_ArcticShrimp.png"); // 请确保图片名与实际一致
        ImageView imageView = new ImageView(image);
        imageView.setFitWidth(image.getWidth() * 0.5);
        imageView.setFitHeight(image.getHeight() * 0.5);
        return FXGL.entityBuilder()
                .type(EntityType.Fish)
                .at(data.getX(), data.getY())
                .viewWithBBox(imageView)
                .with(new comgame.components.MovementComponent())
                .zIndex(2)
                .buildAndAttach();
    }

    @Spawns("CaveShark")
    public Entity newCaveShark(SpawnData data) {
        Image image = new Image("/assets/textures/fish_Caveshark.png");
        ImageView imageView = new ImageView(image);
        imageView.setFitWidth(image.getWidth() * 4.4);
        imageView.setFitHeight(image.getHeight() * 4.4);
        return FXGL.entityBuilder()
                .type(EntityType.Fish)
                .at(data.getX(), data.getY())
                .viewWithBBox(imageView)
                .with(new comgame.components.KingFishMovementComponent())
                .zIndex(1)
                .buildAndAttach();
    }
}